// uni-request.js
const baseURL = 'https://manage.jwk2022.cn/openapiv2/index/getBrandCate'; 

const uniRequest = (options) => {
  return new Promise((resolve, reject) => {
    uni.request({
      url: `${baseURL}${options.url}`, // 拼接基础 URL
      method: options.method || 'GET',
      data: options.data || {},
      header: options.header || {
        'Content-Type': 'application/json'
      },
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data); // 解析成功的数据
        } else {
          reject(new Error(`请求失败，状态码: ${res.statusCode}`));
        }
      },
      fail: (err) => {
        reject(err); // 处理请求失败的情况
      }
    });
  });
};

export default uniRequest;